Embodiments of the invention relate generally to electronic devices and circuits and, more particularly, relate to methods, devices, and computer-readable media for performing floating-point operations.
The Institute of Electrical and Electronic Engineers (IEEE) 754 standard (e.g., IEEE 754-1985: Standard for Binary Floating-Point Arithmetic (1985), and superseding standard IEEE 754-2008, which are incorporated herein by reference in their entireties for all purposes) governs binary floating-point arithmetic and the representation of number formats, basic operations, conversions, and exceptional conditions. IEEE 754 provides definitions for four levels of precision, two of the most commonly used of which are listed in Table 1 below.
TABLE 1LevelWidthRangePrecisionsingle32 bits±1.18 × 10−38 to ±3.4 × 1038about 7 decimalprecisiondigitsdouble64 bits±2.23 × 10−308 to ±1.80 × 10308about 15 decimalprecisiondigits
The IEEE 754 standard also defines representations for positive and negative infinity, negative zero, five exceptions to handle invalid results, such as division by zero, special values referred to as Not-a-Numbers (NaNs) for representing those exceptions, denormal numbers for representing numbers less than the ranges shown in Table 1, and five rounding modes.
Floating-point numbers in IEEE 754 format include three fields; namely, a sign bit, biased exponent, and fraction. For example, the decimal number 0.156251010 represented in binary is 0.001012 (that is, ⅛+ 1/32), wherein numbers in subscript indicate the base. Analogous to scientific notation, in which numbers are written to have a single non-zero digit to the left of the decimal point, numbers in IEEE 754 format are written to have a single 1 bit or significand to the left of the binary point. The significand is multiplied by the appropriate power of two to compensate for shifting the bits left by three positions as follows:0.001012=1.012×2−3.  (1)Thus, a fraction of the number in (1) above is “0.012” and an exponent of this number is “−3.”